package cn.dengta.webapp.user.vo;

import java.util.Date;
import java.util.Map;

import cn.dengta.common.model.ValueProxyImpl;
import cn.dengta.common.util.Formats;
import cn.dengta.context.model.WesKit;
import cn.dengta.webapp.base.vo.AbstractVO;
import cn.dengta.webapp.user.entity.Complain;
import cn.dengta.webapp.user.entity.Moment;
import cn.dengta.webapp.user.model.ComplainStatus;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import me.codeplayer.util.X;

@Setter
@Getter
@Accessors(chain = true)
public class ComplainVO extends AbstractVO<Complain> {

	/** 用户ID */
	public Map<String, Object> user;
	public Map<String, Object> verifyUser;
	public Map<String, Object> agent;
	/** 用户ID */
	public Map<String, Object> toUser;
	public Map<String, Object> toAgent;
	/** 举报类型 */
	private Long typeId;
	/** 举报类型 */
	private String typeName;
	/** 关联目标 */
	public Object assoc;
	/** 内容 */
	private String content;
	/** 0-待处理，1-已删除/已警告，2-已忽略,3-已禁用 */
	/** 审核人 */
	protected Long verifyUserId;
	/** 审核时间 */
	protected Date verifyTime;
	/** 业务状态 */
	protected Integer status;
	/** 信息 */
	protected String verifyRemark;
	/** 图片地址 */
	private String images;
	/** 冻结时间 */
	protected transient Date freezeTime;

	/** 举报人id */
	private Long userId;
	/** 举报群id */
	private Long imId;
	/** 举报类型 */
	private String groupName;
	/** 渠道名称 */
	private String channelName;

	/** 马甲包 */
	public WesKit wesKit;

	public static ComplainVO from(Complain source) {
		return copy(source, ComplainVO::new);
	}

	public static ComplainVO fromGroup(Complain source) {
		ComplainVO complainVO = copy(source, ComplainVO::new);
		complainVO.setImId(source.getToUserId());
		complainVO.setGroupName(source.getNickname());
		complainVO.setUserId(source.getUserId());
		return complainVO;
	}

	public String getAddTime_() {
		return super.getAddTime_();
	}

	public String getStatus_() {
		return X.map(ComplainStatus.of(status), ComplainStatus::getLabel);
	}

	public String getVerifyTime_() {
		return Formats.formatDefDate(verifyTime);
	}

	public String getFreezeTime_() {
		return Formats.formatDefDate(freezeTime);
	}

	public void putAssoc(Object o) {
		if (o != null) {
			if (Moment.class.isAssignableFrom(o.getClass())) {
				assoc = MomentVO.from((Moment) o);
			} else {
				assoc = o;
			}
		}
	}

	public String getWesKit_() {
		return ValueProxyImpl.label(wesKit);
	}

}
